package com.qingke.qixi.command;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.qingke.qixi.App;

public abstract class Command {
		
	protected SqlSession session = null;
	
	public abstract void execute();
	
	public SqlSession getSession(){
		if(session==null){
			InputStream is = App.class.getClassLoader().getResourceAsStream("resources/mybatis_conf.xml");
			SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
	    	session = sessionFactory.openSession();
		}
		return session;
	}
	
}
